package com.example.demo.example1.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;
import java.util.Collection;

/**
 * Created by pengwan on 2017/7/23.
 */
@Entity
@Table(name = "teacher")
public class Teacher extends EntityId{
    @Column(name = "teacher_name")
    private String name;
    @Embedded
    private Address address;

    @ManyToOne // 关系所有者
    @JoinColumn(name = "department_id")
    private Department department;

    @OneToMany(mappedBy = "teacher") // 关系反方
    @JsonIgnore // 防止陷入了死循环
    private Collection<Course> courses;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public Department getDepartment() {
        return department;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }

    public Collection<Course> getCourses() {
        return courses;
    }

    public void setCourses(Collection<Course> courses) {
        this.courses = courses;
    }
}
